package com.yiwei.zhh.fragment;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.yiwei.zhh.R;
import com.yiwei.zhh.adapter.CommissionRankingAdapter;
import com.yiwei.zhh.model.ShareRankingModel;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by xsooy-pc on 18-6-22.
 */

public class CommissionRankingFragment extends BaseFragment {
    @BindView(R.id.list)
    RecyclerView list;
    Unbinder unbinder;
    @BindView(R.id.layout_empty)
    LinearLayout layoutEmpty;
    private List<ShareRankingModel.DataBean.TodayListBean> totalData;
    private CommissionRankingAdapter adapter;

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_commission_ranking;
    }

    @Override
    protected void initView() {
        adapter = new CommissionRankingAdapter(getContext());
        list.setNestedScrollingEnabled(false);
        list.setAdapter(adapter);
        if (totalData != null) {
            adapter.update(totalData);
            if(adapter.getItemCount()==0){
                layoutEmpty.setVisibility(View.VISIBLE);
            }else {
                layoutEmpty.setVisibility(View.GONE);
            }
        }
    }

    public void setData(List<ShareRankingModel.DataBean.TodayListBean> data) {
        this.totalData = data;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
